//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <iostream>

#include "DatasetModelEvaluation.h"
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
using namespace std;
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
int main (int argc, char** argv) {
  
  DatasetModelEvaluation* datasetModelEvaluation = NULL;
  
  if (argc < 6) {
    
    cout << "Error in the input parameters! Must by like: " << endl;
    cout << "./EvaluateInstanceByModelWeight <Filename of Arff File>";
    cout <<                                " <Filename of XML file with the Models>";
    cout <<                                " <Ligand name>";
    cout <<                                " <Scheme>";
    cout <<                                " <Filename Out>";
    cout << endl;
    
    return 0;
    
  }
  else {
    
    datasetModelEvaluation = new DatasetModelEvaluation ();
    
    cout << "---------------------------------------------------------------------------------" << endl;
    cout << "                Filename of ARFF File : " << argv[1] << endl;
    cout << " Filename of XML file with the Models : " << argv[2] << endl;
    cout << "                          Ligand name : " << argv[3] << endl;
    cout << "                               Scheme : " << argv[4] << endl;
    cout << "                         Filename Out : " << argv[5] << endl;
    cout << "---------------------------------------------------------------------------------" << endl;
    
    cout << "Preparing Files..." << endl;
    datasetModelEvaluation->FilenameARFFIn()->In(argv[1]);
    datasetModelEvaluation->BindingSitePrediction()->FilenameXMLModels()->In(argv[2]);
    datasetModelEvaluation->BindingSitePrediction()->XMLModels()->FilenameIn()->In(argv[2]);
    datasetModelEvaluation->BindingSitePrediction()->XMLModels()->LigandName()->In(argv[3]);
    datasetModelEvaluation->BindingSitePrediction()->Scheme()->In(argv[4]);
    datasetModelEvaluation->FilenameOut()->In(argv[5]);
    
  }
  
  cout << "Loading data..." << endl;
  if (!datasetModelEvaluation->LoadData())
    cout << "Error loading data..." << endl;
  
  cout << "Evaluating each instance with the model..." << endl;
  if (!datasetModelEvaluation->EvaluateWithModel())
    cout << "Error evaluating each instance with the model..." << endl;
  
  cout << "Writing results..." << endl;
  if (!datasetModelEvaluation->WriteResults())
    cout << "Error writing results..." << endl;
  
  cout << "Finished..." << endl << "Good Bye" << endl;
  
  if (datasetModelEvaluation) delete datasetModelEvaluation;
  
  return EXIT_SUCCESS;
  
}
//---------------------------------------------------------------------------------------------------------------------------------------------------------//
//---------------------------------------------------------------------------------------------------------------------------------------------------------//

